//
//  ByCellLocationCity.m
//  mijifen_ios
//
//  Created by 朱凯 on 2017/10/31.
//  Copyright © 2017年 itboye. All rights reserved.
//

#import "ByCellLocationCity.h"

@implementation ByCellLocationCity
{
    UIImageView *_locationView;
    UILabel     *_cityLabel;
}
- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
        
        self.backgroundColor = [UIColor whiteColor];
        self.layer.cornerRadius = 2;
        self.layer.borderColor = BY_LINE_COLOR.CGColor;
        self.layer.borderWidth = 1;
        [self setupUI];
    }
    return self;
}
- (void)setupUI {
    
    _locationView = [[UIImageView alloc] init];
    _locationView.backgroundColor = BY_RED_COLOR;
    [self.contentView addSubview:_locationView];
    
    _cityLabel = [[UILabel alloc] init];
    _cityLabel.adjustsFontSizeToFitWidth = true;
    _cityLabel.numberOfLines = 2;
    _cityLabel.text = @"";
    _cityLabel.font = FONT(14);
    _cityLabel.textAlignment = NSTextAlignmentCenter;
    _cityLabel.textColor = [UIColor blackColor];
    [self.contentView addSubview:_cityLabel];
    
    [_cityLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView).insets(UIEdgeInsetsMake(0, 5, 0, 5));
    }];
}

- (void)setCity:(NSString *)city {
    
    _city = city;
    _cityLabel.text = city;
}

- (void)setIsLocation:(BOOL)isLocation {
    
    _isLocation = isLocation;
    [_locationView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(15, 15));
        make.centerY.equalTo(@0);
        make.left.equalTo(@5);
    }];
    [_cityLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_locationView.mas_right).offset(5);
        make.top.bottom.equalTo(@0);
        make.right.equalTo(@-5);
    }];
    
}
@end
